import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import {resolve} from "path"

// https://vite.dev/config/
export default defineConfig({
  plugins: [vue()],

  server:{
    //配置一个本地主机
    host: "localhost",
    //默认5179，
    port: 3000,
    //当执行pnpm自动打开窗口
    open: true,
    //代理
    proxy: {
      "/api": {
        target: "http://localhost:8080",
        changeOrigin: true,
        rewrite: url => url.replace(/^\/api/, "/api/v1")
      }
    }
  },
  //配置别名，在项目中目录的src代替为@符号
  resolve: {
    alias: [{
      find: "@",
      replacement: resolve(__dirname,"src")
    }]
  }
})
